﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace LetLord.Models
{
    public enum AccountType { Tenant = 1, Landlord = 2, EstateAgent = 3 }

    [Table("UserProfile")]
    public class UserProfile
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int UserId { get; set; }

        [Display(Name = "Username")]
        [Required(ErrorMessage="Username is required.")]
        public string UserName { get; set; }

        [Display(Name = "First name")]
        [Required(ErrorMessage = "First name is required.")]
        public string FirstName { get; set; }

        [Display(Name = "Last name")]
        [Required(ErrorMessage = "Last name is required.")]
        public string LastName { get; set; }

        [Display(Name = "Email")]
        [Required(ErrorMessage = "Email is required.")]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }

        [Required(ErrorMessage = "Account type is required.")]
        public AccountType AccountType;

        public virtual string AccountTypeString
        {
            get { return AccountType.ToString(); }
            set
            {
                AccountType newValue;
                if (Enum.TryParse(value, out newValue))
                { AccountType = newValue; }
            }
        }
    }

}